package com.wisemoresystem.seal.action.log;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wisemoresystem.seal.base.action.ProjBaseAction;
import com.wisemoresystem.seal.service.BankService;
import com.wisemoresystem.seal.service.MacLogService;
import com.wisemoresystem.seal.util.json.JsonTools;

/**
 * 设备日志
 * 
 * @author 张永宣
 *
 */
@Controller("ixMacLog")
@Scope("prototype")
@RequestMapping("/ix/log/mac")
public class MacLogAction extends ProjBaseAction {
	@Autowired
	private MacLogService macLogService;
	@Autowired
	private BankService bService;
	/**
	 * 机构列表
	 * @param bank_id 机构id
	 * @return
	 */
	@RequestMapping("/tree")
	public ModelAndView tree(String bank_id) {

		List<Map<String, Object>> list = bService.selectUserBank();
		String bankJson = JsonTools.toJson(list);

		ModelAndView mv = new ModelAndView("/jsp/log/mac/tree");
		mv.addObject("bankJson", bankJson);
		mv.addObject("bank_id", bank_id);
		return mv;
	}
	/**
	 * 机构印控仪列表
	 * @param bank_id  机构id
	 * @return
	 */
	@RequestMapping("/list")
	public ModelAndView list(String srh_name, String srh_start, String srh_end,
			String bank_id) {

		List<Map<String, Object>> list = macLogService.selectMacLogList(
				srh_name, srh_start, srh_end, bank_id, page);

		ModelAndView mv = new ModelAndView("jsp/log/mac/list");
		mv.addObject("list", list);
		mv.addObject("bank_id", bank_id);
		mv.addObject("srh_name", srh_name);
		mv.addObject("srh_start", srh_start);
		mv.addObject("srh_end", srh_end);
		return mv;
	}

}
